package com.laolei.service.demo;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@EnableEurekaClient
@SpringBootApplication
public class SpringEurekaServiceApplication {
	@Autowired DiscoveryClient discoveryClient;
	public static void main(String[] args) {
		SpringApplication.run(SpringEurekaServiceApplication.class, args);
	}

	private Logger logger = LoggerFactory.getLogger(this.getClass());
	
	@GetMapping("/sum") int sum(@RequestParam int a,@RequestParam int b) {
		logger.info("收到请求,请求参数  a: {}, b: {}",a,b);
		System.err.println(discoveryClient.getLocalServiceInstance().getUri());
		return a+b;
	}
}
